<template>
  <div class="tab-detail">
    <el-tabs type="border-card" v-model="activeName" @tab-click="handleSwitchTab">
      <el-tab-pane label="项目详情" name="base">
        <ProjectBase  :id='tab_id_group.base' > </ProjectBase>
      </el-tab-pane>
      <el-tab-pane label="推荐" name="cv">
        <CVTAB :project_id="tab_id_group.cv" :candidate_id="candidate_id" :tab="tab"> </CVTAB>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>
<script>
import CVTAB from '@/views/candidate/components/cvTab'
import ProjectBase from '@/views/project/components/projectBase'
export default {
  name: 'projectDetail',
  components: { CVTAB, ProjectBase },
  data() {
    return {
      tab_id_group: {
        id: '',
        base: '',
        cv: ''
      },
      tab: 'all',
      candidate_id: '',
      activeName: ''
    }
  },
  created() {
    const params = this.$route.params
    if (params.id) {
      this.tab_id_group.id = params.id
    } else {
      this.$message.error('项目id不存在')
      return
    }

    if (params.tab) {
      this.activeName = params.tab
    } else {
      this.activeName = 'base'
    }

    this.$set(this.tab_id_group, this.activeName, params.id)
  },
  methods: {
    handleSwitchTab(selected_tab, event) {
      this.activeName = selected_tab.name
      this.tab_id_group[this.activeName] = this.tab_id_group.id
    }
  }
}
</script>
<style scoped>
  .tab-detail {
    padding: 10px 20px;
  }
</style>

